package org.com.android.utility;

import java.util.HashMap;
import java.util.Map;

import org.com.android.constant.Constant;

import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.util.Log;



public class Utility {
	
	public static Map<String, String> readconf(SharedPreferences settings) {		
		Map<String, String> conf = new HashMap<String, String>();
		
		conf.put("username", settings.getString("username", "ryan"));
		conf.put("password", settings.getString("password", "00095313"));
		conf.put("server", settings.getString("server","http://3d-print.cn:3000"));
		conf.put("stamp", settings.getString("stamp", "1982-10-01 00:00:00"));
		conf.put("entity", settings.getString("entity", "nanjing"));

		Log.v("main::readconf", "username:" + conf.get("username"));
		Log.v("main::readconf", "password:" + conf.get("password"));
		Log.v("main::readconf", "server:" + conf.get("server"));
		Log.v("main::readconf", "stamp:" + conf.get("stamp"));
		Log.v("main::readconf", "entity:" + conf.get("entity"));

		return conf;
	}
	
	public static void saveconf(SharedPreferences settings, Map<String, String> conf) {
		Editor confeditor = settings.edit();
		for (Map.Entry<String, String> entry : conf.entrySet()) {
			confeditor.putString(entry.getKey(), entry.getValue());
		}
		confeditor.commit();
	}
}